package cn.zwx.common.dynamictp.nacos.refresher;

import org.dromara.dynamictp.core.refresher.AbstractRefresher;
import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.lang.NonNull;

/**
 * @author zhangwenxue
 */
public class CloudNacosRefresher extends AbstractRefresher implements SmartApplicationListener {

    public boolean supportsEventType(@NonNull Class<? extends ApplicationEvent> eventType) {
        return RefreshScopeRefreshedEvent.class.isAssignableFrom(eventType);
    }

    public void onApplicationEvent(@NonNull ApplicationEvent event) {
        if (event instanceof RefreshScopeRefreshedEvent) {
            this.doRefresh(this.dtpProperties);
        }

    }
}